package com.rajaev.dtu.tractor.infrastructure.base.errors;


public class BusinessException extends RuntimeException  {

    private int errorCode;

    private String innerErrorMsg;

    private String outErrorMsg;


    public BusinessException(ErrorCodes errorCodes) {
        super();
        this.errorCode = errorCodes.getErrorCode();
        this.innerErrorMsg = errorCodes.getInnerErrorMsg();
        this.outErrorMsg = errorCodes.getOutErrorMsg();
    }

    public BusinessException(String errMsg) {
        super();
        this.errorCode = ErrorCodes.ERR_SYSTEM.getErrorCode();
        this.innerErrorMsg =errMsg;
        this.outErrorMsg = errMsg;
    }


    public BusinessException(int errorCode, String innerErrorMsg, String outErrorMsg) {
        this.errorCode = errorCode;
        this.innerErrorMsg = innerErrorMsg;
        this.outErrorMsg = outErrorMsg;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getInnerErrorMsg() {
        return innerErrorMsg;
    }

    public void setInnerErrorMsg(String innerErrorMsg) {
        this.innerErrorMsg = innerErrorMsg;
    }

    public String getOutErrorMsg() {
        return outErrorMsg;
    }

    public void setOutErrorMsg(String outErrorMsg) {
        this.outErrorMsg = outErrorMsg;
    }

    class Builder{

        private int errorCode;

        private String innerErrorMsg;

        private String outErrorMsg;

        public Builder() {
        }

        Builder errorCode(int errorCode){
            this.errorCode  = errorCode;
            return this;
        }


        Builder innerErrorMsg(String innerErrorMsg){
            this.innerErrorMsg  = innerErrorMsg;
            return this;
        }

        Builder outErrorMsg(String outErrorMsg){
            this.outErrorMsg  = outErrorMsg;
            return this;
        }

        public BusinessException build(){
            BusinessException businessException = new BusinessException(this.errorCode,
                    this.innerErrorMsg,this.outErrorMsg);
            return businessException;
        }



    }
}
